﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="IWebWF.Administration_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>IWebWF - Administration</title>
    <style type="text/css">
        .style1
        {
            width: 500px;
        }
        .style2
        {
            width: 20px;
        }
        .style3
        {
            text-align: right;
        }
        .style4
        {
            text-align: right;
            width: 273px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <h2>
        IWebWF Administration</h2>
    <p>
        <asp:LinkButton ID="lnkBack" runat="server" PostBackUrl="~/Default.aspx">Back to 
        Main</asp:LinkButton>
    </p>
    <asp:Menu ID="AdministrationMenu" runat="server" BackColor="#E3EAEB" DynamicHorizontalOffset="2"
        Font-Names="Verdana" Font-Size="1.0em" ForeColor="#666666" Orientation="Horizontal"
        StaticSubMenuIndent="10px" OnMenuItemClick="AdministrationMenu_MenuItemClick">
        <StaticSelectedStyle BackColor="Yellow" />
        <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
        <DynamicHoverStyle BackColor="#666666" ForeColor="White" />
        <DynamicMenuStyle BackColor="#E3EAEB" />
        <DynamicSelectedStyle BackColor="#1C5E55" />
        <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
        <StaticHoverStyle BackColor="#666666" ForeColor="White" />
        <Items>
            <asp:MenuItem Text="General Settings" ToolTip="Basic application settings" Value="General Settings">
            </asp:MenuItem>
            <asp:MenuItem Text="Status" Value="Status"></asp:MenuItem>
            <asp:MenuItem Text="User Management" ToolTip="Add delete and edit users" Value="User Management">
            </asp:MenuItem>
            <asp:MenuItem Text="Application Log" ToolTip="Applications events and errors" Value="Application Log">
            </asp:MenuItem>
            <asp:MenuItem Text="Sample Client" ToolTip="Sample client to call Sample Workflow"
                Value="Sample Client"></asp:MenuItem>
        </Items>
    </asp:Menu>
    <asp:MultiView ID="mvAdministration" runat="server">
        <asp:View ID="vwGeneralSettings" runat="server">
            <h2>
                General Settings</h2>
            <table align="left" cellpadding="4" class="style1">
                <tr>
                    <td class="style4">
                        Version:
                    </td>
                    <td class="style2">
                        &nbsp;
                    </td>
                    <td>
                        <asp:Label ID="lblVersion" runat="server"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td class="style4">
                        Maximum password attempts:
                    </td>
                    <td class="style2">
                        &nbsp;
                    </td>
                    <td>
                        <asp:TextBox ID="txtMaxPasswordAttempts" runat="server" Columns="3" MaxLength="8"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="vMaximumPasswordAttempts" runat="server" ControlToValidate="txtMaxPasswordAttempts"
                            ErrorMessage="Maxium password attempts must have a value">*</asp:RequiredFieldValidator>
                        <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="txtMaxPasswordAttempts"
                            ErrorMessage="Maxium password attempts must be a number" MaximumValue="999999"
                            MinimumValue="0" Type="Integer">*</asp:RangeValidator>
                    </td>
                </tr>
                <tr>
                    <td class="style4">
                        &nbsp;
                    </td>
                    <td class="style2">
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td class="style4">
                        SMTP Server and port:
                    </td>
                    <td class="style2">
                        &nbsp;
                    </td>
                    <td>
                        <asp:TextBox ID="txtSMTPEmailServer" runat="server" MaxLength="50"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="style4">
                        SMTP Authendication:
                    </td>
                    <td class="style2">
                        &nbsp;
                    </td>
                    <td>
                        <asp:RadioButtonList ID="rbAuthendication" runat="server" RepeatDirection="Horizontal">
                            <asp:ListItem Selected="True" Value="0">Anonymous</asp:ListItem>
                            <asp:ListItem Value="1">Basic</asp:ListItem>
                            <asp:ListItem Value="2">NTLM</asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                <tr>
                    <td class="style4">
                        Use secure SMTP access:
                    </td>
                    <td class="style2">
                        &nbsp;
                    </td>
                    <td>
                        <asp:CheckBox ID="chkSecureAccess" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td class="style4">
                        SMTP Username:
                    </td>
                    <td class="style2">
                        &nbsp;
                    </td>
                    <td>
                        <asp:TextBox ID="txtSMTPUsername" runat="server" MaxLength="50"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="style4">
                        SMTP Password:
                    </td>
                    <td class="style2">
                        &nbsp;
                    </td>
                    <td>
                        <asp:TextBox ID="txtSMTPPassword" runat="server" MaxLength="50"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="style4">
                        SMTP &quot;From&quot; email address:
                    </td>
                    <td class="style2">
                        &nbsp;
                    </td>
                    <td>
                        <asp:TextBox ID="txtSMTPFrom" runat="server" Columns="40" MaxLength="50"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="style4">
                        &nbsp;
                    </td>
                    <td class="style2">
                        &nbsp;
                    </td>
                    <td>
                        <asp:LinkButton ID="lnkTestEmail" runat="server" OnClick="lnkTestEmail_Click" ToolTip="This uses the settings on the form right now, not the last saved settings.">[Send 
                        Test Email]</asp:LinkButton>
                    </td>
                </tr>
                <tr>
                    <td class="style4">
                        &nbsp;
                    </td>
                    <td class="style2">
                        &nbsp;
                    </td>
                    <td>
                    </td>
                </tr>
                <tr>
                    <td class="style3" colspan="3">
                        <asp:ValidationSummary ID="VSummary" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td class="style4">
                        <asp:Label ID="lblUpdated" runat="server" EnableViewState="False" ForeColor="Blue"></asp:Label>
                    </td>
                    <td class="style2">
                        &nbsp;
                    </td>
                    <td>
                        <asp:Button ID="btnUpdateSettings" runat="server" OnClick="btnUpdateSettings_Click"
                            Text="Update Settings" />
                    </td>
                </tr>
            </table>
        </asp:View>
        <asp:View ID="vwUserManagement" runat="server">
            <h2>
                User Management</h2>
            <p>
                <asp:ListView ID="lvUsers" runat="server" DataKeyNames="UserID" DataSourceID="LDSUsers"
                    InsertItemPosition="LastItem" OnItemInserted="lvUsers_ItemInserted" OnItemUpdated="lvUsers_ItemUpdated">
                    <LayoutTemplate>
                        <table id="Table1" runat="server">
                            <tr id="Tr1" runat="server">
                                <td id="Td1" runat="server">
                                    <table id="itemPlaceholderContainer" runat="server" border="0" style="">
                                        <tr id="Tr2" runat="server" style="">
                                            <th id="Th1" runat="server">
                                            </th>
                                            <th id="Th2" runat="server">
                                                UserID
                                            </th>
                                            <th id="Th3" runat="server">
                                                User Name
                                            </th>
                                            <th id="Th4" runat="server">
                                                Password
                                            </th>
                                            <th id="Th5" runat="server">
                                                First Name
                                            </th>
                                            <th id="Th6" runat="server">
                                                Last Name
                                            </th>
                                            <th id="Th7" runat="server">
                                                Email
                                            </th>
                                            <th id="Th8" runat="server">
                                                Role
                                            </th>
                                            <th id="Th9" runat="server">
                                                Active
                                            </th>
                                            <th id="Th10" runat="server">
                                                SuperUser
                                            </th>
                                        </tr>
                                        <tr id="itemPlaceholder" runat="server">
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr id="Tr3" runat="server">
                                <td id="Td2" runat="server" style="">
                                    <asp:DataPager ID="DataPager1" runat="server">
                                        <Fields>
                                            <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False"
                                                ShowPreviousPageButton="False" />
                                            <asp:NumericPagerField />
                                            <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False"
                                                ShowPreviousPageButton="False" />
                                        </Fields>
                                    </asp:DataPager>
                                </td>
                            </tr>
                        </table>
                    </LayoutTemplate>
                    <InsertItemTemplate>
                        <tr style="">
                            <td>
                                <br />
                                <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" ValidationGroup="Insert" /><br />
                                <br />
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                <br />
                                <asp:TextBox ID="UserNameTextBox" runat="server" Text='<%# Bind("UserName") %>' MaxLength="50"
                                    ValidationGroup="Insert" /><br />
                                <asp:RequiredFieldValidator ID="valUserName" runat="server" ErrorMessage="User Name is required"
                                    ControlToValidate="UserNameTextBox" ValidationGroup="Insert"></asp:RequiredFieldValidator>
                            </td>
                            <td>
                                <br />
                                <asp:TextBox ID="PasswordTextBox" runat="server" Text='<%# Bind("Password") %>' MaxLength="50"
                                    TextMode="Password" ValidationGroup="Insert" /><br />
                                <asp:RequiredFieldValidator ID="valPassword" runat="server" ErrorMessage="Password is required"
                                    ControlToValidate="PasswordTextBox" ValidationGroup="Insert"></asp:RequiredFieldValidator>
                            </td>
                            <td>
                                <br />
                                <asp:TextBox ID="FirstNameTextBox" runat="server" Text='<%# Bind("FirstName") %>'
                                    MaxLength="50" /><br />
                                <br />
                            </td>
                            <td>
                                <br />
                                <asp:TextBox ID="LastNameTextBox" runat="server" Text='<%# Bind("LastName") %>' MaxLength="50" /><br />
                                <br />
                            </td>
                            <td>
                                <br />
                                <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>' MaxLength="50" /><br />
                                <br />
                            </td>
                            <td>
                                <br />
                                <asp:DropDownList ID="ddlRoles" runat="server" SelectedValue='<%# Bind("Role") %>'>
                                    <asp:ListItem>Administrators</asp:ListItem>
                                    <asp:ListItem Selected="True">Users</asp:ListItem>
                                </asp:DropDownList>
                                <br />
                                <br />
                            </td>
                            <td>
                                <br />
                                <asp:CheckBox ID="ActiveCheckBox" runat="server" Checked='<%# Bind("Active") %>' /><br />
                                <br />
                            </td>
                            <td>
                                <br />
                                <asp:CheckBox ID="SuperUserCheckBox" runat="server" Checked='<%# Bind("SuperUser") %>' /><br />
                                <br />
                            </td>
                        </tr>
                    </InsertItemTemplate>
                    <EmptyDataTemplate>
                        <table id="Table2" runat="server" style="">
                            <tr>
                                <td>
                                    No data was returned.
                                </td>
                            </tr>
                        </table>
                    </EmptyDataTemplate>
                    <EditItemTemplate>
                        <tr style="">
                            <td>
                                <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" ValidationGroup="Edit" />
                                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="False" /><br />
                                <br />
                            </td>
                            <td>
                                <asp:Label ID="UserIDLabel1" runat="server" Text='<%# Eval("UserID") %>' /><br />
                                <br />
                            </td>
                            <td>
                                <asp:Label ID="lblUserName" runat="server" Text='<%# Eval("UserName") %>' /><br />
                                <br />
                            </td>
                            <td>
                                <asp:TextBox ID="PasswordTextBox" runat="server" Text='<%# Bind("Password") %>' MaxLength="50" /><br />
                                <asp:RequiredFieldValidator ID="valPassword" runat="server" ErrorMessage="Password is required"
                                    ControlToValidate="PasswordTextBox" ValidationGroup="Edit"></asp:RequiredFieldValidator>
                            </td>
                            <td>
                                <asp:TextBox ID="FirstNameTextBox" runat="server" Text='<%# Bind("FirstName") %>'
                                    MaxLength="50" /><br />
                                <br />
                            </td>
                            <td>
                                <asp:TextBox ID="LastNameTextBox" runat="server" Text='<%# Bind("LastName") %>' MaxLength="50" /><br />
                                <br />
                            </td>
                            <td>
                                <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>' MaxLength="50"
                                    Columns="40" /><br />
                                <br />
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlRoles" runat="server" SelectedValue='<%# Bind("Role") %>'>
                                    <asp:ListItem>Administrators</asp:ListItem>
                                    <asp:ListItem>Users</asp:ListItem>
                                </asp:DropDownList>
                                <br />
                                <br />
                            </td>
                            <td>
                                <asp:CheckBox ID="ActiveCheckBox" runat="server" Checked='<%# Bind("Active") %>' /><br />
                                <br />
                            </td>
                            <td>
                                <asp:CheckBox ID="SuperUserCheckBox" runat="server" Checked='<%# Bind("SuperUser") %>' /><br />
                                <br />
                            </td>
                        </tr>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <tr style="">
                            <td>
                                <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you certain you want to delete ?');" />
                                <asp:Button ID="EditButton" CausesValidation="False" runat="server" CommandName="Edit"
                                    Text="Edit" />
                            </td>
                            <td>
                                <asp:Label ID="UserIDLabel" runat="server" Text='<%# Eval("UserID") %>' />
                            </td>
                            <td>
                                <asp:Label ID="UserNameLabel" runat="server" Text='<%# Eval("UserName") %>' />
                            </td>
                            <td>
                                <asp:Label ID="PasswordLabel" runat="server" Text='*******' />
                            </td>
                            <td>
                                <asp:Label ID="FirstNameLabel" runat="server" Text='<%# Eval("FirstName") %>' />
                            </td>
                            <td>
                                <asp:Label ID="LastNameLabel" runat="server" Text='<%# Eval("LastName") %>' />
                            </td>
                            <td>
                                <asp:Label ID="EmailLabel" runat="server" Text='<%# Eval("Email") %>' />
                            </td>
                            <td>
                                <asp:Label ID="txtRole" runat="server" Text='<%# Eval("Role") %>' />
                            </td>
                            <td>
                                <asp:CheckBox ID="ActiveCheckBox" runat="server" Checked='<%# Eval("Active") %>'
                                    Enabled="false" />
                            </td>
                            <td>
                                <asp:CheckBox ID="SuperUserCheckBox" runat="server" Checked='<%# Eval("SuperUser") %>'
                                    Enabled="false" />
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:ListView>
            </p>
            <p>
                <asp:Label ID="lblError" runat="server" EnableViewState="False" Font-Bold="True"
                    ForeColor="Red"></asp:Label>
            </p>
        </asp:View>
        <asp:View ID="vwApplicationLog" runat="server">
            <h2>
                Application Log
            </h2>
            <p>
                <asp:LinkButton ID="lnkRefresh" runat="server" OnClick="lnkRefresh_Click">[Refresh]</asp:LinkButton>
            </p>
            <p>
                <asp:GridView ID="gvApplicationLog" runat="server" AllowPaging="True" AllowSorting="True"
                    AutoGenerateColumns="False" CellPadding="4" DataKeyNames="LogID" DataSourceID="LDSApplicationLog"
                    ForeColor="#333333" GridLines="None" Width="100%">
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <Columns>
                        <asp:BoundField DataField="LogID" HeaderText="LogID" InsertVisible="False" ReadOnly="True"
                            SortExpression="LogID" />
                        <asp:BoundField DataField="UserName" HeaderText="User Name" SortExpression="UserName" />
                        <asp:BoundField DataField="LogDescription" HeaderText="Description" SortExpression="LogDescription" />
                        <asp:BoundField DataField="LogDate" HeaderText="Date" SortExpression="LogDate" />
                    </Columns>
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <EmptyDataTemplate>
                        No Log Data
                    </EmptyDataTemplate>
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <EditRowStyle BackColor="#999999" />
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                </asp:GridView>
            </p>
        </asp:View>
        <asp:View ID="vwClient" runat="server">
            <h2>
                Sample Client</h2>
            <p>
                <i>Note: if using IIS7 the webservice application must have it&#39;s Application pool
                    set to &quot;Classic .NET AppPool&quot;</i></p>
            <p>
                Webservice URL:
                <asp:TextBox ID="txtWebserviceURL" runat="server" Columns="120"></asp:TextBox>
            </p>
            <p>
                Current WorkflowID:&nbsp;
                <asp:TextBox ID="txtCurrentWorkflowID" runat="server" Columns="50"></asp:TextBox>
            </p>
            <asp:Button ID="btnCreateVacationRequest" runat="server" OnClick="btnCreateSampleRequest_Click"
                Text="Start Workflow" />
            <br />
            <br />
            <asp:Label ID="lblWorkflowStarted" runat="server" EnableViewState="False" ForeColor="Red"
                Text="Workflow Started" Visible="False"></asp:Label>
            <br />
            <hr />
            <p>
                Enter Status:
                <asp:TextBox ID="txtWorkflowStatus" runat="server" Columns="10"></asp:TextBox>
            </p>
            <p>
                <asp:Button ID="btnSetStatus" runat="server" OnClick="btnSetStatus_Click" Text="Set Status" />
            </p>
            <hr />
            <p>
                Workflow Status:
                <asp:Label ID="lblRequestStatus" runat="server"></asp:Label>
            </p>
            <p>
                <asp:Button ID="btnGetStatus" runat="server" OnClick="btnGetStatus_Click" Text="Get Worlkflow Status " />
            </p>
            <hr />
            <p>
                <asp:Button ID="btnStopWorkflow" runat="server" OnClick="btnStopWorkflow_Click" Text="Stop Workflow" />
            </p>
            <p>
                <asp:Label ID="lblWorkflowStopped" runat="server" EnableViewState="False" ForeColor="Red"
                    Text="Workflow Stopped" Visible="False"></asp:Label>
            </p>
        </asp:View>
        <asp:View ID="vwStatus" runat="server">
            <h2>
                Workflow Status</h2>
            <p>
                <asp:LinkButton ID="lnkRefreshStatus" runat="server" 
                    OnClick="lnkRefreshStatus_Click">[Refresh]</asp:LinkButton>
            </p>
            <asp:GridView ID="gvStatus" runat="server" AllowPaging="True" 
                AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" 
                DataKeyNames="uidInstanceID" DataSourceID="LDSInstanceState" 
                ForeColor="#333333" GridLines="None" Width="100%" 
                onselectedindexchanged="gvStatus_SelectedIndexChanged">
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <Columns>
                    <asp:ButtonField CommandName="Select" DataTextField="uidInstanceID" 
                        HeaderText="GUID" />
                    <asp:BoundField DataField="unlocked" HeaderText="unlocked" 
                        SortExpression="unlocked" />
                    <asp:BoundField DataField="blocked" HeaderText="blocked" 
                        SortExpression="blocked" />
                    <asp:BoundField DataField="modified" HeaderText="modified" 
                        SortExpression="modified" />
                    <asp:BoundField DataField="nextTimer" HeaderText="nextTimer" 
                        SortExpression="nextTimer" />
                </Columns>
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <EmptyDataTemplate>
                    No Data
                </EmptyDataTemplate>
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#999999" />
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            </asp:GridView>
            <br />
            <br />
            <br />
            <br />
            <br />
        </asp:View>
        <asp:View ID="vwWorkflowDetails" runat="server">
            <h2>
                WorkflowDetails</h2>
            <asp:LinkButton ID="lnkBackFromDetails" runat="server" 
                onclick="lnkBackFromDetails_Click">[Back]</asp:LinkButton>
            <br />
            <br />
            <asp:Label ID="lblWorkflowDetails" runat="server"></asp:Label>
            <br />
            <br />
            <br />
        </asp:View>
    </asp:MultiView>
    <asp:LinqDataSource ID="LDSApplicationLog" runat="server" ContextTypeName="IWebWFCore.IWebWFDataContext"
        OrderBy="LogDate desc" TableName="IWebWFLogs">
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="LDSUsers" runat="server" ContextTypeName="IWebWFCore.IWebWFDataContext"
        EnableDelete="True" EnableInsert="True" EnableUpdate="True" TableName="IWebWFUsers">
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="LDSInstanceState" runat="server" ContextTypeName="IWebWFCore.IWebWFDataContext"
        TableName="InstanceStates">
    </asp:LinqDataSource>
    </form>
</body>
</html>
